#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> ans(n, vector<int>(n));
    int x = 1;
    int index = 0;
    for (int i = 0; i < n; i++) ans[0][i] = x++;
    for (int i = 1; i < n; i++)
    {
        int j = 0;
        for (int k = 0; k < i; k++, j++)
            ans[i][j] = ans[k][index];
        index++;
        for (; j < n; j++)
            ans[i][j] = x++;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            cout << ans[i][j] << ' ';
        cout << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}